<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<%@ include file="/WEB-INF/views/include/easyui.jsp"%>
<script src="${ctx}/static/plugins/My97DatePicker/WdatePicker.js" type="text/javascript"></script>

</head>
<body style="font-family: '微软雅黑'">
<div id="tb" style="padding:5px;height:auto">
        <div>
        	<form id="searchFrom" action="">
       	        <input type="text" name="filter_LIKES_userName" class="easyui-validatebox" data-options="width:150,prompt: '姓名'"/>
       	        <input type="text" name="filter_LIKES_userCode" class="easyui-validatebox" data-options="width:150,prompt: '员工号'"/>
       	        <input type="text" name="filter_LIKES_telephone" class="easyui-validatebox" data-options="width:150,prompt: '手机号'"/>
       	        <input type="text" name="filter_LIKES_userDept" class="easyui-validatebox" data-options="width:150,prompt: '营业部'"/>
		        <span class="toolbar-item dialog-tool-separator"></span>
		        <a href="javascript(0)" class="easyui-linkbutton" iconCls="icon-search" plain="true" onclick="cx()">查询</a>
			</form>
			<shiro:hasPermission name="lcs:employee:add">
	       		<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="add();">新增</a>
	       		<span class="toolbar-item dialog-tool-separator"></span>
	       	</shiro:hasPermission>
	       	<shiro:hasPermission name="lcs:employee:update">
	            <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="upd()">修改</a>
	            <span class="toolbar-item dialog-tool-separator"></span>
	        </shiro:hasPermission>
        </div> 
        
</div>
<table id="dg"></table> 
<div id="dlg"></div>  
<script type="text/javascript">
var dg;
$(function(){   
	dg=$('#dg').datagrid({    
	method: "get",
    url:'${ctx}/employee/json',
    queryParams:{
    		sort: 'createTime', 
    		order: 'desc'
    		},
    fit : true,
	fitColumns : true,
	border : false,
	striped:true,
	idField : 'id',
	pagination:true,
	rownumbers:true,
	pageNumber:1,
	pageSize : 20,
	pageList : [ 10, 20, 30, 40, 50 ],
	singleSelect:true,
    columns:[[    
		{field:'id',title:'id',hidden:true},  
		{field:'userName',title:'姓名',align:'center',sortable:false,width:40},
		{field:'userCode',title:'员工号',align:'center',sortable:false,width:40},
		{field:'jxId',title:'CRM编号',align:'center',sortable:false,width:40},
        {field:'telephone',title:'手机号',align:'center',sortable:false,width:50}, 
        {field:'cardNo',title:'身份证号',align:'center',sortable:false,width:80},
        {field:'userDept',title:'营业部',align:'center',sortable:false,width:100}, 
        {field:'city',title:'城市',align:'center',sortable:false,width:40}, 
        {field:'post',title:'岗位',align:'center',sortable:false,width:50}, 
        {field:'createTime',title:'创建时间',width:80,align:'center',sortable:false,formatter:function(value,rowData,rowIndex){
			return formatTime(value);
		}}
    ]],
    enableHeaderClickMenu: false,
    enableHeaderContextMenu: false,
    enableRowContextMenu: false,
    toolbar:'#tb'
	});
});

//弹窗增加
function add() {
	d=$("#dlg").dialog({   
	    title: '新增理财师',    
	    width: 380,    
	    height: 300,    
	    href:'${ctx}/employee/create',
	    maximizable:true,
	    modal:true,
	    buttons:[{
			text:'确认',
			handler:function(){
				$("#mainform").submit(); 
				dg.datagrid('reload');
			}
		},{
			text:'取消',
			handler:function(){
					d.panel('close');
				}
		}]
	});
}

//弹窗修改
function upd(){
	var row = dg.datagrid('getSelected');
	if(rowIsNull(row)) return;
	d=$("#dlg").dialog({   
	    title: '修改理财师',    
	    width: 380,    
	    height: 300,   
	    href:'${ctx}/employee/update/'+row.id,
	    maximizable:true,
	    modal:true,
	    buttons:[{
			text:'修改',
			handler:function(){
				$('#mainform').submit(); 
			}
		},{
			text:'取消',
			handler:function(){
					d.panel('close');
				}
		}]
	});
}

//创建查询对象并查询
function cx(){
	var obj=$("#searchFrom").serializeObject();
	obj.filter_LIKES_userName = encodeURIComponent(obj.filter_LIKES_userName);
	obj.filter_LIKES_userDept = encodeURIComponent(obj.filter_LIKES_userDept);
	
	dg.datagrid('reload',obj); 
}

</script>
</body>
</html>